﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CorporateGym.DAL;

namespace BLL
{
    public class MedicalApprovalManager
    {
        private static MedicalApprovalManager m_This;
        private static readonly object sr_SyncObj = new Object();
        public static MedicalApprovalManager Instance
        {
            get
            {
                if (m_This == null)
                {
                    lock (sr_SyncObj)
                    {
                        if (m_This == null)
                        {
                            m_This = new MedicalApprovalManager();
                        }
                    }
                }

                return m_This;
            }
        }

        private MedicalApprovalManager()
        {
        }

        public int AddMedicalApproval(DateTime i_ExpirationDate)
        {
            return DataAccess.Instance.AddMedicalApproval(i_ExpirationDate);
        }

        public bool UpdateMedicalApproval(MedicalApproval i_Approval)
        {
            return DataAccess.Instance.UpdateMedicalApprovalExpirationDate(i_Approval.Id, i_Approval.ExpirationDate);
        }

        public MedicalApproval GetMedicalApprovalById(int i_Id)
        {
            CorporateGymDB.MedicalApprovalRow row = DataAccess.Instance.GetMediaclApprovalById(i_Id);
            MedicalApproval approval = MedicalApproval.CreateFromRow(row);
            return approval;
        }
    }
}
